<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>4-10 动态组件</title>
</head>
<body>
<div id="app">
    <label>选择要加载的组件</label>
    <select v-model="name">
        <option value="one">1</option>
        <option value="two">2</option>
        <option value="three">3</option>
    </select>
    <keep-alive>
    <component :is="name"></component>
    </keep-alive>
</div>
<script src="../lib/vue.global.js" type="text/javascript"></script>
<script>
    const { createApp } = Vue

    const vm = createApp({
      data() {
        return {
          name: 'one'
        }
      },
      components: {
        'one': {template: `<div>我是组件1<input type="text"></div>`},
        'two': {template: `<div>我是组件2<input type="text"></div>`},
        'three': {template: `<div>我是组件3<input type="text"></div>`},
      }
    }).mount('#app')
</script>
</body>
</html>
